home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / knowhow4 / net.h < prev    next >
C/C++ Source or Header  |  1994-10-10  |  2KB  |  66 lines

  1. #ifndef __NET_H_
  2. #define __NET_H_
  3.  
  4. #include "geom.h"
  5. #include "alloc.h"
  6.  
  7. #define DELTA 20
  8.  
  9.  
  10. struct NODE
  11.     {
  12.     loc pos;
  13.     int view;
  14.  
  15.     NODE* n1;
  16.     NODE* n2;
  17.     NODE* n3;
  18.     NODE* n4;
  19.  
  20.     NODE(loc p, int v = 0, NODE* l = NULL, NODE* r = NULL, NODE* u = NULL,
  21.         NODE* d = NULL)
  22.         { pos = p; n1 = l; n2 = r; n3 = u; n4 = d; view = v; }
  23.     NODE(NODE* node) { pos = node->pos; n1 = node->n1; n2 = node->n2;
  24.         n3 = node->n3; n4 = node->n4; view = node->view; }
  25.  
  26.     int in_node(loc pos);
  27.     };
  28. //////////////////
  29. /*    Supposing we already have NODEs which are linked at the this->next
  30.       level, we need structure for list manipulations. There are: memory
  31.       allocation, insertions and so on. ATTENTION!!! No check procedures.
  32. */
  33. struct NET
  34.     {
  35.     NODE** list;
  36.     int used;
  37.     int total;
  38.  
  39.     NODE* current;
  40.  
  41.     NET() { used = total = 0; list = NULL; current = NULL; }
  42.     ~NET();
  43.  
  44.     void add(NODE* t) { insert(t, used); }
  45.     void insert(NODE* t, int number);
  46.     NODE* remove(int number);
  47.  
  48.     loc closest(loc p);  // Find the knot which is closest to loc p.
  49.  
  50. /*    find_way() function is used to build way from current knote to another
  51.       one with pos coordinate. We suppose that source net is acyclic graph.
  52.       We also suppose that tree is binary.
  53.       find() function finds way from upper level knote to lower level one.
  54.       Algorythm:
  55.           a. Find way from start knote to the graph top.
  56.           b. Find way from destination knote to the graph top.
  57.           c. Compare and exclude duplications. For example, having two graphs
  58.              a-b-c-d and a-b-c-e-f, we should obtain d-c-e-f graph. Last
  59.              knot duplicated is nor excluded.
  60. */
  61.     int find(NET* net, loc pos);
  62.     NET* find_way(loc pos, loc pos1);
  63.     };
  64.  
  65. #endif __NET_H_
  66.